﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;

namespace Gui.Controls.ExtendedTabControl
{
    public partial class TabMenu : UserControl
    {
        private bool selected;
        private int menuIndex;

        public TabMenu()
        {
            InitializeComponent();

            this.BackColor = TabMenuStyle.MenuBackColor;
            this.ForeColor = TabMenuStyle.MenuForeColor;
        }

        public int MenuIndex
        {
            get
            {
                return this.menuIndex;
            }
            set
            {
                this.menuIndex = value;
            }
        }

        public bool Selected
        {
            get
            {
                return this.selected;
            }
            set
            {
                this.selected = value;
            }
        }

        public string SetTextMenu
        {
            set
            {
                this.menuText.Text = value;
            }
        }

        private void menuText_MouseEnter(object sender, EventArgs e)
        {
            if (!Selected)
            {
                this.BackColor = TabMenuStyle.MenuBackColorHover;
                this.ForeColor = TabMenuStyle.MenuForeColorHover;
            }
        }

        private void menuText_MouseLeave(object sender, EventArgs e)
        {
            if (!Selected)
            {
                this.BackColor = TabMenuStyle.MenuBackColor;
                this.ForeColor = TabMenuStyle.MenuForeColor;
            }
        }

        private void menuText_MouseDown(object sender, MouseEventArgs e)
        {
            foreach (Control menu in this.Parent.Controls)
            {
                (menu as TabMenu).Selected = false;
                menu.BackColor = TabMenuStyle.MenuBackColor;
                menu.ForeColor = TabMenuStyle.MenuForeColor;
            }

            this.Selected = true;
            this.BackColor = TabMenuStyle.MenuBackColorSelected;
            this.ForeColor = TabMenuStyle.MenuForeColorSelected;

            TabMasksLoader.ShowTab(this.MenuIndex);
        }
    }
}
